const merge = require('webpack-merge')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const commonConfig = require('./webpack.config.common')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OSS = require('webpack-aliyun-oss-plugin')

const prodConfig = {
  mode: 'production', //'development' 和 'production'
  optimization: {
    minimize: true,
  },
  output: {
    publicPath: '',
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: 'styles/[name].[hash].css',
      chunkFilename: 'styles/[id].[hash].css',
    }),
    new OSS({
      from: ['/dist/**'],
      dist: '',
      region: '',
      ak: '',
      sk: '',
      bucket: 'v',
      logToLocal: true,
    }),
  ], // performance: false // 不提示打包过程中性能的一些问题,如打包文件超过244kb等
}

module.exports = merge(commonConfig, prodConfig)
